﻿
Option Strict On : Option Explicit On : Option Compare Binary : Option Infer On

Imports System
Imports System.Collections.ObjectModel
Imports System.Text.RegularExpressions


Namespace Code.Coloriser

    ''' <summary>
    ''' Default code coloriser for Asm (assembly language)
    ''' </summary>
    ''' <remarks></remarks>
    Friend Class AsmCodeColoriser
        Inherits IColorTokenProvider

        '       Sub New()
        '           Me.Keywords = New String() {"AAA", "AAD", "AAM", "AAS", "ADC", "ADD", "AND", "ARPL", "BOUND", "BSF", "BSR", "BSWAP", "BT", "BTC", "BTR", _
        '                                       "BTS", "CALL", "CBW", "CDQ", "CLC", "CLD", "CLI", "CLTS", "CMC", "CMP", "CMPS", "CMPSB", "CMPSD", "CMPSW", _
        '                                       "CMPXCHG", "CWD", "CWDE", "DAA", "DAS", "DEC", "DIV", "ENTER", "ESC", "F2XM1", "FABS", "FADD", "FADDP", _
        '                                       "FBLD", "FBSTP", "FCHS", "FCLEX", "FCOM", "FCOMP", "FCOMPP", "FCOS", "FDECSTP", "FDISI", "FDIV", _
        '                                       "FDIVP", "FDIVR", "FDIVRP", "FENI", "FFREE", "FIADD", "FICOM", "FICOMP", "FIDIV", "FIDIVR", _
        '                                       "FILD", "FIMUL", "FINCSTP", "FINIT", "FIST", "FISTP", "FISUB", "FISUBR", "FLD", "FLD1", "FLDCW", _
        '                                       "FLDENV", "FLDL2E", "FLDL2T", "FLDLG2", "FLDLN2", "FLDPI", "FLDZ", "FMUL", "FMULP", "FNCLEX", _
        '                                       "FNDISI", "FNENI", "FNINIT", "FNOP", "FNSAVE", "FNSTCW", "FNSTENV", "FNSTSW", "FPATAN", "FPREM", _
        '                                       "FPREM1", "FPTAN", "FRNDINT", "FRSTOR", "FSAVE", "FSCALE", "FSETPM", "FSIN", "FSINCOS", _
        '                                       "FSQRT", "FST", "FSTCW", "FSTENV", "FSTP", "FSTSW", "FSUB", "FSUBP", "FSUBR", "FSUBRP", "FTST", "FUCOM", _
        '                                       "FUCOMP", "FUCOMPP", "FWAIT", "FXAM", "FXCH", "FXTRACT", "FYL2X", "FYL2XP1", "HLT", "IDIV", _
        '                                       "IMUL", "IN", "INC", "INSB", "INSD", "INSW", "INT", "INTO", "INVD", "INVLPG", "IRET", "IRETD", "JA", _
        '                                       "JAE", "JB", "JBE", "JC", "JCXZ", "JE", "JECXZ", "JG", "JGE", "JL", "JLE", "JMP", "JNA", "JNAE", "JNB", "JNBE", _
        '                                       "JNC", "JNE", "JNG", "JNGE", "JNL", "JNLE", "JNO", "JNP", "JNS", "JNZ", "JO", "JP", "JPE", "JPO", "JS", "JZ", _
        '                                       "LAHF", "LAR", "LDS", "LEA", "LEAVE", "LES", "LFS", "LGDT", "LGS", "LIDT", "LLDT", "LMSW", "LOCK", "LODS", _
        '                                       "LODSB", "LODSD", "LODSW", "LOOP", "LOOPD", "LOOPDE", "LOOPDNE", "LOOPDNZ", "LOOPDZ", "LOOPE", _
        '                                       "LOOPNE", "LOOPNZ", "LOOPZ", "LSL", "LSS", "LTR", "MOV", "MOVS", "MOVSB", "MOVSD", "MOVSW", "MOVSX", _
        '                                       "MOVZX", "MUL", "NEG", "NOP", "NOT", "OR", "OUT", "OUTSB", "OUTSD", "OUTSW", "POP", "POPA", "POPAD", _
        '                                       "POPF", "POPFD", "PUSH", "PUSHA", "PUSHAD", "PUSHF", "PUSHFD", "RCL", "RCR", "REP", "REPE", "REPNE", _
        '                                       "REPNZ", "REPZ", "RET", "RETF", "RETN", "ROL", "ROR", "SAHF", "SAL", "SAR", "SBB", "SCAS", "SCASB", "SCASD", _
        '                                       "SCASW", "SEGCS", "SEGDS", "SEGES", "SEGFS", "SEGGS", "SEGSS", "SETA", "SETAE", "SETB", "SETBE", _
        '                                       "SETC", "SETE", "SETG", "SETGE", "SETL", "SETLE", "SETNA", "SETNAE", "SETNB", "SETNBE", _
        '                                       "SETNC", "SETNE", "SETNG", "SETNGE", "SETNL", "SETNLE", "SETNO", "SETNP", "SETNS", "SETNZ", "SETO", _
        '                                       "SETP", "SETPE", "SETPO", "SETS", "SETZ", "SGDT", "SHL", "SHLD", "SHR", "SHRD", "SIDT", "SLDT", "SMSW", _
        '                                       "STC", "STD", "STI", "STOS", "STOSB", "STOSD", "STOSW", "STR", "SUB", "TEST", "VERR", "VERW", "WAIT", _
        '                                       "WBINVD", "XADD", "XCHG", "XLAT", "XOR", _
        '_
        '                                       "AH", "AL", "AND", "AX", "BH", "BL", "BP", "BX", "BYTE", "CH", "CL", "CS", "CX", "DH", "DI", "DL", "DS", _
        '                                       "DWORD", "DX", "EAX", "EBP", "EBX", "ECX", "EDI", "EDX", "EIP", "ES", "ESI", "ESP", "FS", "GS", "HIGH", "LOW", _
        '                                       "MOD", "NOT", "OFFSET", "OR", "PTR", "QWORD", "SHL", "SHR", "SI", "SP", "SS", "ST", "TBYTE", "TYPE", _
        '                                       "WORD", "XOR", _
        '_
        '                                       "ASSUME", "COMMENT", "DB", "DD", "DQ", "DT", "DW", "END", "ENDM", "ENDP", "ENDS", "EQ", "EQU", "EXITM", "EXTRN", _
        '                                       "FAR", "GE", "GROUP", "GT", "INCLUDE", "LABEL", "LARGE", "LE", "LENGTH", "LOCAL", "LT", "MACRO", _
        '                                       "MASK", "NAME", "NEAR", "ORG", "PAGE", "PROC", "PUBLIC", "PURGE", "RECORD", "REPT", "SEG", "SEGMENT", _
        '                                       "SHORT", "SIZE", "SMALL", "STRUC", "SUBTTL", "SYMTYPE", "THIS", "TITLE", "WIDTH"}

        '           Me.m_stringOrCharRegexStr = "("".*?"")"
        '           Me.m_commentRegexStr = "#.*"
        '       End Sub


        Public Overrides ReadOnly Property CaseSensitive() As Boolean
            Get
                Return False
            End Get
        End Property


        Protected Overrides ReadOnly Property CommentRegexStr() As String
            Get
                Return "#[^\r\n]*"
            End Get
        End Property


        Protected Overrides ReadOnly Property StringOrCharRegexStr() As String
            Get
                Return """""|""[^\r\n]*?"""
            End Get
        End Property


        Protected Overrides ReadOnly Property Keywords() As String
            Get
                Return "AAA AAD AAM AAS ADC ADD AND ARPL BOUND BSF BSR BSWAP BT BTC BTR " _
                & "BTS CALL CBW CDQ CLC CLD CLI CLTS CMC CMP CMPS CMPSB CMPSD CMPSW " _
                & "CMPXCHG CWD CWDE DAA DAS DEC DIV ENTER ESC F2XM1 FABS FADD FADDP " _
                & "FBLD FBSTP FCHS FCLEX FCOM FCOMP FCOMPP FCOS FDECSTP FDISI FDIV " _
                & "FDIVP FDIVR FDIVRP FENI FFREE FIADD FICOM FICOMP FIDIV FIDIVR " _
                & "FILD FIMUL FINCSTP FINIT FIST FISTP FISUB FISUBR FLD FLD1 FLDCW " _
                & "FLDENV FLDL2E FLDL2T FLDLG2 FLDLN2 FLDPI FLDZ FMUL FMULP FNCLEX " _
                & "FNDISI FNENI FNINIT FNOP FNSAVE FNSTCW FNSTENV FNSTSW FPATAN FPREM " _
                & "FPREM1 FPTAN FRNDINT FRSTOR FSAVE FSCALE FSETPM FSIN FSINCOS " _
                & "FSQRT FST FSTCW FSTENV FSTP FSTSW FSUB FSUBP FSUBR FSUBRP FTST FUCOM " _
                & "FUCOMP FUCOMPP FWAIT FXAM FXCH FXTRACT FYL2X FYL2XP1 HLT IDIV " _
                & "IMUL IN INC INSB INSD INSW INT INTO INVD INVLPG IRET IRETD JA " _
                & "JAE JB JBE JC JCXZ JE JECXZ JG JGE JL JLE JMP JNA JNAE JNB JNBE " _
                & "JNC JNE JNG JNGE JNL JNLE JNO JNP JNS JNZ JO JP JPE JPO JS JZ " _
                & "LAHF LAR LDS LEA LEAVE LES LFS LGDT LGS LIDT LLDT LMSW LOCK LODS " _
                & "LODSB LODSD LODSW LOOP LOOPD LOOPDE LOOPDNE LOOPDNZ LOOPDZ LOOPE " _
                & "LOOPNE LOOPNZ LOOPZ LSL LSS LTR MOV MOVS MOVSB MOVSD MOVSW MOVSX " _
                & "MOVZX MUL NEG NOP NOT OR OUT OUTSB OUTSD OUTSW POP POPA POPAD " _
                & "POPF POPFD PUSH PUSHA PUSHAD PUSHF PUSHFD RCL RCR REP REPE REPNE " _
                & "REPNZ REPZ RET RETF RETN ROL ROR SAHF SAL SAR SBB SCAS SCASB SCASD " _
                & "SCASW SEGCS SEGDS SEGES SEGFS SEGGS SEGSS SETA SETAE SETB SETBE " _
                & "SETC SETE SETG SETGE SETL SETLE SETNA SETNAE SETNB SETNBE " _
                & "SETNC SETNE SETNG SETNGE SETNL SETNLE SETNO SETNP SETNS SETNZ SETO " _
                & "SETP SETPE SETPO SETS SETZ SGDT SHL SHLD SHR SHRD SIDT SLDT SMSW " _
                & "STC STD STI STOS STOSB STOSD STOSW STR SUB TEST VERR VERW WAIT " _
                & "WBINVD XADD XCHG XLAT XOR " _
 _
                & "AH AL AND AX BH BL BP BX BYTE CH CL CS CX DH DI DL DS " _
                & "DWORD DX EAX EBP EBX ECX EDI EDX EIP ES ESI ESP FS GS HIGH LOW " _
                & "MOD NOT OFFSET OR PTR QWORD SHL SHR SI SP SS ST TBYTE TYPE " _
                & "WORD XOR " _
 _
                & "ASSUME COMMENT DB DD DQ DT DW END ENDM ENDP ENDS EQ EQU EXITM EXTRN " _
                & "FAR GE GROUP GT INCLUDE LABEL LARGE LE LENGTH LOCAL LT MACRO " _
                & "MASK NAME NEAR ORG PAGE PROC PUBLIC PURGE RECORD REPT SEG SEGMENT " _
                & "SHORT SIZE SMALL STRUC SUBTTL SYMTYPE THIS TITLE WIDTH"
            End Get
        End Property

    End Class

End Namespace